package org.csmzxy.class2333.map;

public class Student implements Comparable<Student>{
    private String name;
    private  int score;
    public Student(String name, int score){
        this.name = name;
        this.score = score;
    }

    @Override
    public String toString() {
        return "姓名: " + name + " 成绩: " + score;
    }
    @Override
    public int compareTo(Student s){
        //按照成绩进行排序
        int result = s.score - this.score;
        //按照姓名进行排序
        result = result == 0 ? this.name.compareTo(s.name) : result;
        return  result;
    }
}
